﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddOrEdit.aspx.cs" Inherits="admin_Modules_Course_AddOrEdit" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="/admin/resources/css/base.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        .custom-trigger { background-image: url(/files/images/custom-trigger.gif) !important; }
    </style>
    <script src="/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/ckfinder.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/config.js" type="text/javascript"></script>
    <script src="/plugins/ckeditor/config.js" type="text/javascript"></script>
    <script src="/admin/resources/js/base.js" type="text/javascript"></script>
    <script type="text/javascript">

        //FCKEditor Js API
        var getFckText = function () {
            return CKEDITOR.instances.fckHtmlEditor.getData();
        }

        function BrowseServer() {
            // You can use the "CKFinder" class to render CKFinder in a page:
            var finder = new CKFinder();
            finder.basePath = '/plugins/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
            finder.selectActionFunction = SetFileField;
            finder.popup();
        }

        // This is a sample function which is called when a file is selected in CKFinder.
        function SetFileField(fileUrl) {
            triggerFilm.setValue(fileUrl);
            // document.getElementById('xFilePath').value = fileUrl;
        }


        function loadEditor() {
            var oFCKeditor = CKEDITOR.replace('fckHtmlEditor', {
                customConfig: '/plugins/ckeditor/config.js',
                filebrowserBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserImageBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserFlashBrowseUrl: '/plugins/ckfinder/ckfinder.html?type=Flash',
                filebrowserUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files',
                filebrowserImageUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images',
                filebrowserFlashUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'

            });

            oFCKeditor.BasePath = '/plugins/ckeditor/';
            oFCKeditor.Width = '680px';
            oFCKeditor.Skin = 'v2';
            oFCKeditor.Height = '250px';
            //CKFinder.setupCKEditor(oFCKeditor, { basePath: '/ckfinder/', rememberLastFolder: false });
        }

        function setHtml(html) {
            return CKEDITOR.instances.fckHtmlEditor.setData(html);
        }


        function setCombo(value) {
            if (value == 0) return;
            txtSubject.setValue(value);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <ext:ResourceManager ID="ScriptManager2" runat="server">
            <Listeners>
                <DocumentReady Handler="loadEditor();" />
            </Listeners>
        </ext:ResourceManager>
        <ext:Viewport ID="wdAddOrEditImageCategory" runat="server" Layout="BorderLayout">
            <Items>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <Center>
                        <ext:Panel ID="Panel12" runat="server" Title="Center" Header="false" AutoScroll="true"
                            BodyBorder="true" Border="true" BodyStyle="background-color:#fff; ">
                            <TopBar>
                                <ext:Toolbar ID="Toolbar2" runat="server">
                                    <Items>
                                        <ext:Button Icon="Disk" Text="Cập nhật">
                                            <DirectEvents>
                                                <Click OnEvent="AddOrEdit" Before="valid = #{StatusForm2}.getForm().isValid(); if(valid){ Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving'); } return valid;">
                                                    <ExtraParams>
                                                        <ext:Parameter Name="fckParameter" Mode="Raw" Value="getFckText()" />

                                                    </ExtraParams>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Items>
                                <ext:FormPanel ID="StatusForm2" BodyBorder="false" Header="false" runat="server"
                                    LabelWidth="120" BodyStyle="padding:5px">
                                    <Items>
                                        <ext:SelectBox ID="txtSubject" runat="server" DisplayField="Name" ValueField="ID"
                                            AllowBlank="false" Width="280" EmptyText="Bấm vào chọn môn học" FieldLabel="Môn học">
                                            <Store>
                                                <ext:Store ID="storeSubject" runat="server">
                                                    <Reader>
                                                        <ext:JsonReader>
                                                            <Fields>
                                                                <ext:RecordField Name="Name" />
                                                                <ext:RecordField Name="ID" />
                                                            </Fields>
                                                        </ext:JsonReader>
                                                    </Reader>
                                                    <SortInfo Field="Name" Direction="ASC" />
                                                </ext:Store>
                                            </Store>
                                        </ext:SelectBox>
                                        <ext:TextField runat="server" ID="txtName" FieldLabel="Tên"
                                            Width="280">
                                        </ext:TextField>
                                        <ext:NumberField runat="server" ID="txtPrice" FieldLabel="Giá" Width="280" Note="Ghi cả phần nghìn, ví dụ: 200000">
                                        </ext:NumberField>
                                        <ext:NumberField runat="server" ID="txtNumberOfLearner" FieldLabel="Số lượng học viên" Width="280">
                                        </ext:NumberField>
                                        <ext:DateField runat="server" ID="dtStart" FieldLabel="Ngày bắt đầu" Width="160" Format="dd/MM/yyyy"></ext:DateField>
                                        <ext:Checkbox runat="server" ID="chkExpired" FieldLabel="Hết hạn?"></ext:Checkbox>
                                        <ext:TextArea Width="480" runat="server" ID="txtShortContent" FieldLabel="Nội dung tóm tắt"></ext:TextArea>
                                        <ext:TextArea ID="fckHtmlEditor" Name="fckHtmlEditor" runat="server" FieldLabel="Nội dung">
                                        </ext:TextArea>

                                    </Items>
                                </ext:FormPanel>
                            </Items>
                        </ext:Panel>
                    </Center>
                </ext:BorderLayout>
            </Items>
        </ext:Viewport>
    </form>
</body>
</html>
